home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: alt.msdos.programmer,comp.lang.c
- Subject: Re: Some C problems
- Date: 13 Jan 1996 07:06:08 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Jan13000608@qcd.lanl.gov>
- References: <4d0fjj$eok@lugb.latrobe.edu.au> <4d4pg7$3ot@news.dx.net>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: robmc@shol.com's message of 12 Jan 1996 04:53:27 GMT
-
- --text follows this line--
- In article <4d4pg7$3ot@news.dx.net> robmc@shol.com (Rob McCafferty) writes:
- <snip>
- I believe C assumes numeric constants are signed. Try using 65535U.
-
- Unsuffixed decimal constants are signed unless a long is insufficient
- to hold them, in which case they are unsigned. (If they don't fit into
- an unsigned long, it is an error).
-
- For octal and hexadecimal, they are signed; except if they fit into an
- unsigned int or unsigned long, but not into the corresponding signed
- type.
-
- <snip>
- >How do you use literal constants bigger than words e.g. how would you use
- >the literal constant 1000000 without getting the 'constant out of range'
- >warning/error?
-
- Again, C assumes constants are int unless you tell it otherwise. Make this
- 1000000L.
-
- An ANSI C compiler has to interpret 1000000 and 1000000L identically
- if 1000000 > MAX_INT (because it must fit into an unsigned int, there
- is no possibility of it being an error).
-
- ANSI C compilers assume unsufixed constants to be ints, _unless_ they
- do not fit into an int. In this case, long and unsigned long are
- tried. For octal and hexadecimal constants, unsigned int is tried
- before trying signed and unsigned longs.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-